*( CALC.CMD - CALCULATE NET AMOUNT FOR TRANSACTION HEADERS)
SET MESSAGES OFF
OPEN concomp
SET ERROR MESSAGES OFF
SET VAR vamt1 CURRENCY
SET VAR vamt2 CURRENCY
SET POINTER #2 e2 FOR transx WHERE transid EXISTS
WHILE e2 EQ 0 THEN
  SET VAR vamt1 = 0
  SET VAR vamt2 = 0
  SET VAR vtrans = transid IN #2
  SET POINTER #3 e3 FOR transd WHERE transid = .vtrans
  WHILE e3 EQ 0 THEN
     SET VAR vamt1 = extprice IN #3
     SET VAR vamt2 = (.vamt2 + .vamt1)
     NEXT #3 e3
  ENDWHILE
  CHANGE netamt = .vamt2 IN #2
  NEXT #2 e2
ENDWHILE
CLEAR vamt1 vamt2 vtrans e2 e3
SET MESSAGES ON
SET ERROR MESSAGES ON
RETURN
